﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace InputBox
{
    public partial class Input : Form
    {
        public Input()
        {
            InitializeComponent();
        }
        public Input(string Baslik)
        {
            InitializeComponent();
            this.Text = Baslik;
        }
        public Input(string Baslik, string deger)
        {
            InitializeComponent();
            this.Text = Baslik;
            textBox1.Text = deger;
        }
        public static string Yaz()
        {
            Input ini = new Input();
            if (ini.ShowDialog() == DialogResult.OK)
            {
                return ini.textBox1.Text;
            }
            ini.Dispose();
            return "";
        }
        public static string Yaz(string Baslik)
        {
            Input ini = new Input();
            ini.Text = Baslik;
            if (ini.ShowDialog() == DialogResult.OK)
            {
                return ini.textBox1.Text;
            }
            ini.Dispose();
            return "";
        }
        public static string Yaz(string Baslik, string Deger)
        {
            Input ini = new Input();
            ini.Text = Baslik;
            ini.textBox1.Text = Deger;
            ini.textBox1.Select(0, Deger.Length);
            if (ini.ShowDialog() == DialogResult.OK)
            {
                return ini.textBox1.Text;
            }
            ini.Dispose();
            return Deger;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            Close();
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                button1_Click(button1, new EventArgs());
            }
        }




        internal static int Yaz_int(string Baslik, int Deger)
        {
            Input ini = new Input();
            Convert.ToInt32(Deger);
            ini.Text = Baslik;
            ini.textBox1.Text = Deger.ToString();
            ini.textBox1.Select(0, Deger.ToString().Length);
            if (ini.ShowDialog() == DialogResult.OK)
            {
                return int.Parse(ini.textBox1.Text);
            }
            ini.Dispose();
            return 0;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void Input_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode==Keys.Escape)
            {
                button2_Click(null, null);
            }
        }
    
    
    
    }
}
